//
//  main.c
//  调整奇数偶数顺序
//
//  Created by 卜绎皓 on 2022/2/22.
//

#include <stdio.h>


void swap(int arr[],int sz){
    int left = 0;
    int right = sz - 1;
    while (left<right) {
        while (arr[left] % 2 == 1) {
            left++;
        }
        while (arr[right] % 2 ==0) {
            right--;
        }
        if (left<right) {
            int temp = arr[left];
            arr[left] = arr[right];
            arr[right] = temp;
        }
    }
}


int main(){
    int arr[] = {0,1,2,3,4,5,6,7,8,9};
    int sz = sizeof(arr)/sizeof(arr[0]);
    int i = 0;
    printf("原数组：");
    for(i=0;i<sz;i++){
        printf("%d,",arr[i]);
    }
    swap(arr,sz);
    printf("调整后：");
    for(i=0;i<sz;i++){
        printf("%d,",arr[i]);
    }
    return 0;
}
